<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>登录页面</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <link rel="stylesheet" href="/js/bootstrap-4.1.1-dist/css/bootstrap.min.css">
    <script src="/js/jquery/jquery.min.js"></script>
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="/css/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/css/reset.css">
    <link rel="stylesheet" href="/css/login.css">
    <script src="/js/bootstrap-4.1.1-dist/js/bootstrap.min.js"></script>
    <!--序列化表单-->
    <script src="/js/plugins/form/jquery.form.js"></script>
    <!--移动端专用弹框-->
    <script src="/js/plugins/dialog2/dialog.min.js"></script>
    <link rel="stylesheet" href="/js/plugins/dialog2/dialog.css">

    <script>
        $(function () {
            $("#loginForm").ajaxForm(function (data) {
                if (data.success) {
                    //将当前用户信息共享到session中(把json对象转成字符串在存储)
                    sessionStorage.setItem("user", JSON.stringify(data.result));
                    window.parent.location.href = "/index.html";
                } else {
                    $(document).dialog({
                        content: data.msg,
                    });
                }

            });
            //鼠标失去焦点事件
            $("#email").mouseout(function (data) {
                //$("#profile-img").remove();
                var email = $("#email").val();

                $.get("/users/email", {email: email}, function (data) {
                    console.log(data);
                    $("#headImgUrl").attr("src",data.headImgUrl);

                    /*var img = '<img src="'+data.headImgUrl+'" style="width: 70px;higth:90px;"/>';
                    $("#div").html(img);*/
                })
            })
        });
    </script>
</head>
<body>
<div class="container">
    <h5>登录</h5>

    <div class="card card-container ">
        <div align="center" id="div">
            <img style="width: 70px;higth:90px;" id="headImgUrl" align="center" class="rounded-circle"/>
           <!-- <i id="profile-img" class="fa fa-user-circle fa-5x profile-img" ></i>-->
        </div>


        <form class="form-signin" id="loginForm" action="/sessions" method="post">
            <input type="email" id="email" name="email" value="" class="form-control badge-pill"
                   placeholder="邮箱">
            <input type="password" name="password" value="" class="form-control badge-pill" placeholder="密码">
            <a href="#" class="forgot-password">
                忘记密码？
            </a>
            <button class="btn btn-lg badge-pill" type="submit">登录</button>
        </form>
    </div>


    <a href="register.html" class="registerLink">
        新用户？点击这里注册
    </a>
</div>

</body>
</html>
